import { mapService } from '@/utils/request'

// 查询在线用户列表
export function getLocation(key) {
  return mapService({
    url: 'location/v1/ip',
    method: 'get',
    params: {
      key: key
    }
  })
}

export function getGeoCoder(key, type, params) {
  let body = {
    key: key
  }
  if(type == 'location'){
    body.location = `${params.lat},${params.lng}`
  }else {
    body.address = params
  }
  return mapService({
    url: 'geocoder/v1/',
    method: 'get',
    params:body
  })
}

export function getNavDriving(key, from, to){
  return mapService({
    url: 'direction/v1/driving',
    method: 'get',
    params:{
      key: key,
      from: `${from.lat},${from.lng}`,
      to: `${to.lat},${to.lng}`
    }
  })
}